<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="../../layui/css/layui.css" type="text/css">
    <style>
        body{
            padding: 20px;
        }
    </style>
</head>
<body>
    <form class="layui-form" >
        <div class="layui-form-item">
            <label class="layui-form-label">suer</label>
            <div class="layui-input-block">
            <input type="text" name="suer"   autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">手机</label>
            <div class="layui-input-block">
            <input type="text" name="sphone" required  lay-verify="phone" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">邮箱</label>
            <div class="layui-input-block">
            <input type="text" name="semail" required  lay-verify="email" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">登录名</label>
            <div class="layui-input-block">
            <input type="text" name="login_name" required  lay-verify="" autocomplete="off" class="layui-input">
            </div>
        </div>  
       
        <div class="layui-form-item">
            <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>

<script src="../../layui/layui.js"></script>
<script src="../../js/ajax.js"></script>
<script>

    function child(obj, fn){
        //console.log(obj)
        //获取特定iframe层的索引  此方法一般用于在iframe页关闭自身时用到。
        var index = parent.layer.getFrameIndex(window.name);
        layui.use('form', function(){
            var form = layui.form;
            //form.render();

            //监听提交
            form.on('submit(formDemo)', function(data){
                // 开启加载动画
                
                var index2 = layer.load(2, {time: 10*1000});
             //layer.msg(JSON.stringify(data.field));

                
                //console.log(obj)

                ajax({
                    url: '../php/updata-sys_user.php',
                    data: {
                        data: JSON.stringify(data.field),
                        id_name: 'sid',
                        id: obj.sid
                    },
                    method: 'post',
                    success: function(res){
                        fn(res, data.field);
                        // 关闭加载动画
                        layer.close(index2); 
                        // if(res == 1){
                        //     layer.msg('更新成功'); 
                        //     //parent.location.reload();
                        // }else{
                        //     layer.msg('更新失败, 请联系相关人员!'); 
                        //     //return false;
                        // }
                        // 关闭自身iframe
                        parent.layer.close(index);
                    }
                });
                return false;
            });

        })
    }
</script>
</body>
</html>